package com.foreknow.mapping;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂类
 * 1.单例
 */
public class MappingFactory {
    private static MappingFactory mappingFactory = null;
    private Map<String,EntityMapping> maps = new HashMap<>();
    public static final String GUESTBOOK_MAPPING="guestbookmapping";

    private MappingFactory(){

    }

    public static MappingFactory getInstance(){
        if (mappingFactory==null){
            mappingFactory = new MappingFactory();
            //向Map中保存xxxMapping对象
            mappingFactory.maps.put(GUESTBOOK_MAPPING,new GuestBookMapping());
            //mappingFactory.maps.put("xxxmapping",new xxxMapping());
        }
        return mappingFactory;
    }

    //从Map集合中获取元素的方法
    public EntityMapping getMap(String key){
        return maps.get(key);
    }
}
